package com.example.opencvstudy;

import android.view.Surface;

public class FaceTracker {
    static {
        System.loadLibrary("opencvstudy");
    }
    private long mNativeObj = 0;

    public FaceTracker(String modelPath) {
        this.mNativeObj  =nativeCreateObject(modelPath);
    }

    public void setSurface(Surface surface) {
        nativeSetSurface(mNativeObj,surface);
    }

    public void detect(byte[] inputImage, int width , int height, int rotationDegrees) {
        nativeDetect(mNativeObj,inputImage, width, height, rotationDegrees);
    }
    public void start() {
        nativeStart(mNativeObj);
    }

    public void stop() {
        nativeStop(mNativeObj);
    }

    public void release() {
        nativeDestoryObject(mNativeObj);
        mNativeObj = 0;
    }

    private static  native long nativeCreateObject(String modelPath);

    private static  native void  nativeDestoryObject(long mNativeObj);

    private static  native void  nativeSetSurface(long mNativeObj, Surface surface);

    private static  native void  nativeStart(long mNativeObj);

    private static  native void  nativeStop(long mNativeObj);

    private static  native void  nativeDetect(long mNativeObj,byte[] inputImage,int width,int height,int rotationDegrees);

}
